<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>特产</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
    <style>
    .specialty-desc:before {
        content: '';
        width: 100%;
        height: 100%;    
        position: absolute;
        left: 0;
        top: 0;
        background: linear-gradient(transparent 70%, white);
    }
    </style>
</head>

<body>
    <nav class="navbar navbar-expand-md bg-light">
        <div class="container-fluid">
            <a href="/" class="navbar-brand">首页</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
              <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarSupportedContent">
                <ul class="navbar-nav">
                    <li class="navbar-item"><a href="#" class="nav-link">华北地区</a></li>
                    <li class="navbar-item"><a href="#" class="nav-link">华东地区</a></li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                            中南地区
                        </a>
                        <ul class="dropdown-menu">
                            <li><a class="dropdown-item" href="#">河南</a></li>
                            <li><a class="dropdown-item" href="#">湖北</a></li>
                            <li><a class="dropdown-item" href="#">湖南</a></li>
                            <li><a class="dropdown-item" href="#">广东</a></li>
                            <li><a class="dropdown-item" href="#">广西</a></li>
                            <li><a class="dropdown-item" href="#">海南</a></li>
                        </ul>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                            西北地区
                        </a>
                        <ul class="dropdown-menu">
                            <li><a class="dropdown-item" href="#">陕西</a></li>
                            <li><a class="dropdown-item" href="#">甘肃</a></li>
                            <li><a class="dropdown-item" href="#">宁夏</a></li>
                            <li><a class="dropdown-item" href="#">新疆</a></li>
                        </ul>
                    </li>
                </ul>
                <form class="d-flex" role="search">
                    <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
                    <button class="btn btn-outline-success" type="submit">Search</button>
                </form>
            </div>
        </div>
    </nav>


    <div class="container" style="background-color: #f5f5f5">
        <div class="row p-5 my-2">
            <div class="col-md text-center"><img width="400px" alt="" src="./images/hunan.png"></div>
            <div class="col-md">
                <h1>湖南特产</h1>
                <p>湖南特产丰富多样，以农产品和食品为主，深受各地游客喜爱真中，湖南腊肉以其肥而不腻、甘香醇厚的口感而闻名：湘莲粒人饱满，清香鲜甜，被誉为贡莲”。此外，湖南的茶叶也颐受好评，如安化黑茶和白马毛尖，香气浓郁，口感独特。在水果方面，炎陵黄桃和洞庭银鱼等也是湖南的特色产品，鲜美可口，营养丰富。除了食品，湖南的手工艺品如湘绣、王家族的织锦等也极真特色，精美绝伦。这些特产不仅代表了湖南的丰富文化和历史，也是湖南人民辛勤劳动的结晶，为湖南的经济发展和文化传承做出了重要贡献</p>
            </div>
        </div>
    </div>

    <div class="container">
        <div class="row row-cols-auto row-cols-md-3 row-cols-lg-4 gx-5 gy-3 justify-content-center" id="specialty-container">
            
        </div>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
    <script>
    function SpecialtyCard({ name, desc, imageUrl, tagUrls }) {
        return (`
            <div class="col">
                <div class="card" style="">
                    <img src="${ imageUrl }" class="card-img-top" alt="${ name }" height="286px">
                    <div class="card-body">
                        <h5 class="card-title">
                            <span>${ name }</span>
                            <span class="float-end">${ tagUrls && tagUrls.map(url => `<img src="${ url }" width="20px">`).join('') }</span>
                        </h5>
                        <div style="overflow: hidden; max-height: 200px; position: relative">
                            <p class="card-text specialty-desc">${ desc }</p>
                        </div>
                    </div>
                </div>
            </div>
        `);
    }
    
    document.addEventListener('DOMContentLoaded', function() {
        fetch('data.json')
            .then(resp => resp.json())
            .then(obj => {
                let html = obj
                    .filter(x => x.province == '湖南')
                    .map(x => SpecialtyCard({
                        name: x.name,
                        desc: x.description,
                        imageUrl: x.smallImgUrl,
                        tagUrls: x.tagIcons
                                    .filter(fileName => fileName != '')
                                    .map(fileName => 'images/tag/' + fileName)
                    }))
                    .join('');
                document.getElementById('specialty-container').innerHTML = html;
            })
            .catch(err => console.log(err));
    });
    </script>
</body>

</html>
